package com.example.test;

//        Java遍历一个字符串的每一个字母

//char 转 String      Sting 转 char
public class Five_Traverse {
    public static void main(String[] args) {
        String json = "123%0002^123&#$we*ferfer";


        //indexof  获得指定字符在字符串里第一次出现的下标
        System.out.println(json.indexOf("2"));
        //lastIndexOf  获得指定字符在字符串里第一次出现的下标  返向查询
        System.out.println(json.lastIndexOf("123"));
//1
        for (int i = 0; i < json.length(); i++) {
                char c = json.charAt(i);
            System.out.print(c); //123%0002^123&#$we*ferfer
        }
        System.out.println();
//2
        char[] c=json.toCharArray();
        for(char cc:c){
            System.out.print(cc);
        }
        System.out.println();
//3
        for(int i=0;i<json.length();i++){
            String subStr = json.substring(i, i+1);
            System.out.print(subStr);
            if (subStr == "^"){

            }
        }
    }
}
